﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


public partial class CMS_Admin_block_FriendLink : System.Web.UI.Page
{
    Usas.BLL.Cms.cms_block_common_detail cbcd = new Usas.BLL.Cms.cms_block_common_detail();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            New.Attributes.Add("onclick", "window.open ('FriendLinkSet.aspx?action=add&page=" + Request["page"].ToString() + "&control=" + Request["control"].ToString() + "', '新链接', 'height=600, width=700, toolbar=no, menubar=no, scrollbars=yes,status=no,top=200,left=300');return false;");
            Bind();
        }
    }

    private void Bind()
    {
        DataSet ds = cbcd.GetList("c_b_id=" + Request["control"].ToString() + " and c_type='" + Request["page"].ToString() + "' and c_view != 0");

        RptList.DataSource = ds;
        RptList.DataBind();
    }


    protected void RptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView drv = (DataRowView)e.Item.DataItem;


            LinkButton link = (LinkButton)e.Item.FindControl("link");
            link.Attributes.Add("onclick", "window.open ('FriendLinkSet.aspx?action=edit&page=" + Request["page"].ToString() + "&control=" + Request["control"].ToString() + "&cid=" + drv["c_id"].ToString() + "', '友情链接', 'height=600, width=700, toolbar=no, menubar=no, scrollbars=yes,status=no,top=200,left=300');return false;");

            LinkButton linkDel = (LinkButton)e.Item.FindControl("linkDel");
            linkDel.CommandArgument = drv["c_id"].ToString();
            linkDel.CommandName = "del";
            linkDel.Attributes.Add("onclick", "return confirm('确认删除【" + drv["c_des"].ToString() + "】')");

        }
    }
    protected void RptList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            cbcd.Delete(Convert.ToInt32(e.CommandArgument.ToString()));
            ClientScript.RegisterStartupScript(GetType(), "Msg", "alert('删除成功');location.href='" + Request.Url.ToString() + "'", true);
        }
    }
}
